package jsyf.oa.dao.system;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import jsyf.oa.entity.system.UserLeaveEntity;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

import jsyf.oa.idao.BaseDao;
import jsyf.oa.ientity.IBaseEntity;

/**
 * Created by Administrator on 2018/1/10 0010.
 */
@Repository
public class UserLeaveDao extends BaseDao {

    public UserLeaveDao() {
        super.iBaseEntity = new UserLeaveEntity();
    }

    public List<UserLeaveEntity> getEntityListByCondition(String condition, Object[] params) {
        List<JSONObject> jsonList = getJSONListByCondition(condition, params);
        List<UserLeaveEntity> entityList = new ArrayList<>();
        for (int i = 0; i < jsonList.size(); i++) {
            UserLeaveEntity entity = (UserLeaveEntity) convertJson2Entity(jsonList.get(i));
            entityList.add(entity);
        }
        return entityList;
    }

    @Override
    public IBaseEntity convertJson2Entity(JSONObject json) {
        return JSON.toJavaObject(json, UserLeaveEntity.class);
    }
}

